let fs = require('fs')
function loadPage(url) {
  let http = require('http')
  let pm = new Promise(function(resolve, reject) {
    http
      .get(url, function(res) {
        let html = ''
        res.on('data', function(d) {
          html += d.toString()
        })
        res.on('end', function() {
          resolve(html)
        })
      })
      .on('error', function(e) {
        reject(e)
      })
  })
  return pm
}
let urlName = [
  'myyh5',
  'myyhlb',
  'ahyx8',
  'chuanqi211',
  'myyh6',
  'chuanqi94',
  'sg4',
  'hsjj4',
  'celue17',
  'gcldfl1',
  'myyhfl1',
  'ahphs1',
  'ahyx7',
  'ysdlfl1',
  'ahyx6',
  'sgzj2',
  'rxzgfl1',
  'qjmu1',
  'myjh5',
  'wangyou8',
  'myjh4',
  'qjfbw',
  'ahyx9',
  'myyh4',
  'ysdl2',
  'myjh',
  'mm103',
  'wx8',
  'chuanqi44',
  'gt1',
  'wangyou14',
  'celue30',
  'wx28',
  'sgz11',
  'xianxia54',
  'myyh10',
  'xianxia48',
  'mhj23',
  'chuanqi199',
  'szfl1',
  'yeyou3',
  'chuanqi134',
  'sgz',
  'wangyou67',
  'wx13',
  'wx35',
  'mm97',
  'musz',
  'sgqyz1',
  'mhj22',
  'sg33',
  'mu22',
  'ahyx10',
  'jjmy1',
  'ck4',
  'jjsg9',
  'zzhx14',
  'wx18',
  'chuanqi189',
  'mieshenfl1',
  'mu18',
  'chuanqi105',
  'chuanqi212',
  'wangyou4',
  'gcldfl6',
  'wx29',
  'sg29',
  'chuanqi140',
  'musf4',
  'wdcq9',
  'sgzccz',
  'shfl1',
  'celue23',
  'xianxia13',
  'mhj4',
  'jjsg13',
  'wangyou13',
  'chuanqisf9',
  'wangyou1',
  'sgzdy1',
  'wangyou21',
  'celue34',
  'xianxia45',
  'sgzb',
  'myyh13',
  'jjsg10',
  'mgmu1',
  'celue36',
  'wdcq1',
  'gcldfl5',
  'chuanqi118',
  'myyh12',
  'jtbw1',
  'gcldhdns',
  'wx70',
  'rxzgzcs3',
  'mu14',
  'sg19',
  'myxyx',
  'chuanqi109',
  'celue16',
  'xianxia14',
  'gcld9',
  'xs21',
  'mu12',
  'celue4',
  'xianxia56',
  'wx43',
  'xmry15',
  'my20',
  'gcld13',
  'rxzgzcs2',
  'muhfh',
  'celue8',
  'chuanqi116',
  'sg16',
  'ysdl5',
  'wdcqfl3',
  'xianxia18',
  'wx41',
  'celue20',
  'rxzgzcs4',
  'xianxia44',
  'xianxia23',
  'ah3',
  'mu8',
  'my5',
  'mu3',
  'chuanqi25',
  'szjdz2',
  'dm7',
  'wangyou54',
  'xianxia5',
  'sgz2',
  'xianxia36',
  'aiawa-zy1',
  'sgzdy',
  'chuanqi66',
  'ahyx2',
  'lsjj1',
  'dm8',
  'myyh11',
  'ysdl1',
  'chuanqi127',
  'wangyou3',
  'xianxia21',
  'my2',
  'wangyou32',
  'wangyou5',
  'szlb1',
  'shwj',
  'jihuang2',
  'zsfyfl1',
  'myyh2',
  'wx60',
  'mu33',
  'djsy1',
  'sg30',
  'ahyx3',
  'wangyou34',
  'mu29',
  'xianxia20',
  'chuanqidzy',
  'sgz12jqb',
  'gjqt1',
  'xianxia22',
  'mm100',
  'xmryfl1lyh',
  'sg11',
  'xianxia5zsy',
  'sg1',
  'wangyou47',
  'wx23',
  'chuanqi37',
  'tdzs3',
  'dy1',
  'xianxia40',
  'sg15',
  'tongyong174',
  'chuanqi124',
  'rxzgzcsfl1',
  'yeyou8',
  'myjh2',
  'wx11',
  'mieshenfl1lb',
  'chuanqi15',
  'cqry2',
  'musf5',
  'xs7new',
  'mlj1',
  'hs2',
  'wx30',
  'wx58',
  'chuanqi43',
  'dxz',
  'chuanqi28',
  'chuanqi87',
  'jyjh8',
  'mm91',
  'kjyss',
  'wangyou29',
  'nrjxjy',
  'mu19',
  'chuanqi76',
  'rxzgzcs1',
  'wangyou38',
  'yhjy4',
  'chuanqi9',
  'ah1',
  'xianxia2',
  'chuanqi115',
  'mm99',
  'xianxia9',
  'wangyou69',
  'dm4',
  'sg12',
  'jjsg8',
  'szlbws',
  'chuanqi57',
  'chuanqi91',
  'ljxx',
  'xianxia46',
  'srcs1',
  'celue18',
  'gjqt2lb',
  'xianxia3',
  'sz5',
  'wx53',
  'wx50',
  'chuanqi111',
  'xianxia43',
  'sg22',
  'xmry12',
  'tdzs2',
  'mohuan6',
  'sz3',
  'xs23',
  'chuanqi68',
  'rxsgfl1',
  'wangyou23',
  'xs6',
  'wangyou37',
  'chuanqi39',
  'wkz3',
  'sz1',
  'ntxs3',
  'chuanqi90',
  'xs16',
  'chuanqi93',
  'tdzsfl3',
  'wangyou16',
  'mieshenfl1lyh',
  'mm88',
  'jjsg11',
  'xianxia1',
  'wangyou41',
  'chuanqi131',
  'sg18',
  'chuanqi70',
  'myyhkfb',
  'chuanqi46',
  'qxzb',
  'xs13',
  'myfbw2',
  'tongyong51',
  'xs2',
  'dm1',
  'mhj3',
  'sgz9',
  'myxyx1',
  'sgz10jqb',
  'wx12',
  'chuanqi7',
  'qxz',
  'mhxy2',
  'sxjfl1',
  'xs12',
  'wangyou25',
  'sg14',
  'qlz',
  'chuanqi78',
  'wangyou12',
  'sg31',
  'jjsg7',
  'mu4',
  'dm9',
  'my8',
  'gongsha2',
  'chuanqi63',
  'wangyou35',
  'jjsg6',
  'ry2',
  'shlb1',
  'xs8',
  'hs1',
  'xianxia3m1',
  'wangyou9',
  'wdcq6',
  'mohuan2',
  'wls6',
  'chuanqi101',
  'xmry13',
  'sghxz',
  'wangyou11',
  'tjkd4lb',
  'rxzgzcslb3ws',
  'jsxwfl1lyh',
  'chuanqi75',
  'my4',
  'wxsf1',
  'wdcqfl4',
  'myyh18',
  'chuanqi26',
  'wx68',
  'gcldsf1',
  'sz4',
  'xianxia31',
  'my21',
  'my3',
  'wx29ws',
  'mieshen7',
  'lsqyfl1',
  'sh1',
  'xs4',
  'dlls1',
  'myyh1',
  'gs2',
  'xs8zsy',
  'chuanqi54',
  'gcldfl3',
  'celue1',
  'yeyou13',
  'sgzz2',
  'sg10',
  'tmld2',
  'wangyou39',
  'ptsf1',
  'tdzsfl1',
  'xianxia55',
  'sg13',
  'ssz',
  'dl5',
  'dts3',
  'xianxia11',
  'chuanqisf11',
  'wangyou10',
  'mohuan1',
  'wx42',
  'chuanqi71',
  'wx20',
  'ahyx4',
  'wx2',
  'chuanqi69',
  'jzcq3lyh',
  'wangyou20',
  'mu5',
  'jszn1',
  'chuanqisf10',
  'mujw',
  'gcld6',
  'jszn2',
  'bfsg4',
  'qxx1',
  'jsxw2',
  'celue25',
  'sgqxzfl1',
  'gcld14',
  'mieshen1',
  'wangyou36',
  'xianxia12',
  'cqms1',
  'xs1',
  'wx67',
  'wangyou62',
  'chuanqi100',
  'chuanqi24',
  'mm98',
  'mu28',
  'sg20',
  'myyh9',
  'celue27',
  'mieshenhd',
  'sgsj2',
  'gcldfl2',
  'chuanqi42',
  'chuanqi97',
  'qbgd1',
  'mu15zsy',
  'wx9',
  'gsfl1',
  'mohuan5',
  'wangyou26',
  'mhj2',
  'qkzj1',
  'muhh',
  'chuanqi52',
  'xianxia6',
  'chuanqi64',
  'mzxc',
  'gcld10',
  'qb1',
  'mohuan9',
  'sjs',
  'mu13',
  'wx5',
  'mieshenfl2',
  'hsfl2',
  'jyjxfl3',
  'gongsha1',
  'chuanqi60',
  'chuanqi123',
  'chuanqi121',
  'chuanqi23',
  'my9',
  'ylm',
  'ck1',
  'chuanqi40',
  'cqry1',
  'mohuan3',
  'wx24',
  'sg8',
  'sjqt1',
  'ntxs5',
  'my7',
  'kun1',
  'mieshenkfb',
  'chuanqisf4',
  'blzz',
  'xianxia17',
  'mu6',
  'wx15',
  'xs3',
  'gmly',
  'wsdzzzq',
  'chuanqi122',
  'sz6',
  'chuanqi30',
  'chuanqi141',
  'xs9',
  'chuanqi5',
  'chuanqi65',
  'mu11',
  'mjtxhd',
  'chuanqi88',
  'chuanqi27',
  'sgz9jqb',
  'dtszj',
  'ftj8lyh',
  'chuanqi29',
  'chuanqi13',
  'sg9',
  'tongyong61',
  'mhxy1',
  'sg17',
  'fbdl4',
  'long1',
  'chuanqi74',
  'xmry6',
  'mu35',
  'myfbw',
  'jihuang3',
  'mieshenfl2lyh',
  'chuanqi2',
  'myyh1lyh',
  'chuanqi31',
  'hsjj2',
  'bfsg5',
  'ht4',
  'sxj3',
  'ryyx',
  'chuanqi36',
  'wangyou19',
  'chuanqi16',
  'ltzn5',
  'xmry2lb',
  'sgzpz',
  'xs7',
  'dm10',
  'sgqyz',
  'sgz11jqb',
  'wangyou30',
  'ht3',
  'gjqt3',
  'ltzn8',
  'yeyou4',
  'bfsg3',
  'xmry10',
  'chuanqi139',
  'chuanqi32',
  'xlyx1',
  'chuanqi108',
  'wangyou56',
  'rxzgcslb1',
  'chuanqi12',
  'qjcsfl2',
  'chuanqi113',
  'dpcq1',
  'lzns11sm',
  'wsdzz10',
  'dgtx',
  'chuanqisf6',
  'jjsggw',
  'mm98sm',
  'dldl1',
  'wd7',
  'mohuan16',
  'lsqy12',
  'sgqxznew',
  'wx49',
  'wx19',
  'mu23',
  'sszj',
  'myyh3',
  'yeyou10',
  'yeyou7',
  'mm115',
  'jjsgxn1',
  'yhjx3',
  'msgw',
  'wangyou24',
  'qjcsfl1',
  'wx10',
  'celue29',
  'wx4',
  'chuanqi22',
  'chuanqi150',
  'shlbws',
  'chuanqi114',
  'chuanqi58',
  'ltzn3',
  'tdzs1',
  'seqing3',
  'gcldzq',
  'mohuan4',
  'yxwd2',
  'gjqtnew',
  'yhjy5',
  'chuanqi67',
  'gjqt',
  'chuanqi110',
  'myyhgw',
  'jxqytd1',
  'fbdl3',
  'tlbbsf1',
  'chuanqi106',
  'wangyou10new',
  'xmry7',
  'tj',
  'wx61ws',
  'wx51',
  'xs14',
  'dhxy',
  'sywz2',
  'chuanqisf8',
  'yxwd6',
  'gedou1',
  'yeyou2',
  'mhj1',
  'xianxia8',
  'yeyou6',
  'jyjx8',
  'bfsg7',
  'hssm',
  'xianxia39',
  'jueshitangmen1',
  'wangyou45',
  'hazh3',
  'mm111',
  'chuanqi55',
  'chuanqi19',
  'dxxjj01',
  'chuanqi81',
  'mffyjfl1lyh',
  'zmjh',
  'lsqy1',
  'hdx3lb',
  'mm106',
  'zmq4',
  'wx26',
  'rxzgzq',
  'xs17',
  'wangyou22',
  'ptyj',
  'wx39',
  'sgsj',
  'qh1',
  'dts4',
  'qjcs4',
  'qnyh1',
  'wangyou28',
  'chuanqi84',
  'sgqxz3',
  'hdx3',
  'jjdjr1',
  'bdsb7',
  'jxtcj2',
  'gs3',
  'rxsg',
  'xs20',
  'mu10',
  'sg2',
  'much',
  'zh',
  'muhlw',
  'mu24',
  'fbdlfl1',
  'qxz4',
  'zsyx',
  'chuanqi83',
  'sgzz5',
  'rw1',
  'mffyj4',
  'mm87',
  'hsfl1',
  'chuanqi178',
  'tymyd1',
  'dtsfl1',
  'chuanqi64ns',
  'qxz8',
  'cqry4',
  'yeyou5',
  'chuanqi38',
  'fbdlfl3',
  'ltzn10',
  'gjqt2',
  'rxzgzcslb2',
  'ttxy4',
  'sgzz4',
  'sxj4',
  'ahzlxy',
  'dsglzjb',
  'ltzn4',
  'tycq',
  'zgzn',
  'sgqxz2',
  'jyjxfl1',
  'xianxia10',
  'jsxw1',
  'myyh16',
  'wangyou17',
  'sgqyz2',
  'xqjfl1',
  'my18',
  'my',
  'jizhan1',
  'chuanqi47',
  'xs5',
  'lzns11',
  'mm34',
  'sszj2',
  'lsqy8',
  'rxjh1',
  'mm16',
  'tt',
  'my6',
  'wangyou18',
  'chuanqi56',
  'my10',
  'mm11',
  'ltzn9',
  'wx14',
  'chuanqi59',
  'wangyou33',
  'wx36',
  'wx33',
  'chuanqi174',
  'qjcs1',
  'hs4',
  'xianxia42',
  'jyjh10',
  'ahcq2',
  'qn',
  'xianxia15',
  'qjcs3',
  'chuanqi51',
  'jyjh4',
  'chuanqi89',
  'jyjx7',
  'myjh3',
  'mlzj',
  'qjcs5',
  'zhq',
  'sywz4',
  'wsdzz7',
  'wangyou7',
  'yhjxlb',
  'chuanqi107',
  'sqsd',
  'zmqgw',
  'jyjx4',
  'dhdww',
  'hc1',
  'chuanqi35',
  'zzhx',
  'ftjfly3',
  'tjkdfl2',
  'mm33',
  'chuanqi34',
  'hazg14',
  'qsmy1',
  'wsdzz3',
  'jyjx9',
  'gwlr',
  'qj1',
  'wsdzzfl4',
  'zmqlb1',
  'xmry9',
  'jyjh9',
  'chuanqi41',
  'yhjxfl',
  'mm10',
  'sg23',
  'xs18',
  'sg28',
  'jdxyfl1',
  'cqmsfl1',
  'mieshen4',
  'jxqyhomepage',
  'gcldhd',
  'smyx1',
  'mm21',
  'yeyou9',
  'kmg',
  'mujn',
  'in',
  'qxz1',
  'ldjfl2',
  'chuanqi45',
  'hdzyfl3',
  'sgqxz',
  'chuanqi18',
  'xmry1',
  'xianxia16',
  'sz8',
  'chuanqi62',
  'wx22',
  'hndj2',
  'xyll9',
  'jyjx1',
  'dldlfl1',
  'dpcq',
  'chuanqi154',
  'mm23',
  'dldl5',
  'ahcq1',
  'qizhan1',
  'chuanqi92',
  'djssg1',
  'wdcqhd',
  'xmry11',
  'mm92',
  'chuanqi98',
  'gt3',
  'jtfsfl1',
  'sgz12wljqb',
  'hdx1',
  'ftj8lb',
  'chuanqi44new',
  'ptyj1',
  'myyh7',
  'mohuan8',
  'xmgqj',
  'mu28ws',
  'qs6',
  'dldl2',
  'hdxfl2',
  'jyjh1',
  'gongshasf1',
  'ltzn6',
  'ysdl3',
  'handao1',
  'jtfssf2',
  'mu21',
  'kun2',
  'mm29',
  'mm113',
  'yeyou3zsy',
  'jyjh7',
  'celue14',
  'mohuan10',
  'chuanqi77',
  'chuanqi96',
  'dhmfb',
  'txj1',
  'xj',
  'chuanqi191',
  'wd1'
]

let imgInfo = []
for (let i = 0; i < 1; i++) {
  loadPage(
    'http://p.2217.com/tg/myyh/' + urlName[i] + '/adp_new/ccid/?fy=no'
  ).then(function(d) {
    // d 就是当前页的html内容
    // bad
    // console.log('d', d)
    // let regex = /\/generalpage\//
    // let index = d.search(regex)
    // let imgId =
    //   d.substr(index + 13, 4).charAt(3) === '/'
    //     ? d.substr(index + 13, 3).charAt(2) === '/'
    //       ? d.substr(index + 13, 2)
    //       : d.substr(index + 13, 3)
    //     : d.substr(index + 13, 4)
    // good
    // let regex2 = /\/generalpage\/\d{3,4}/
    // let img_id = d.match(regex2)[0].match(/\d+/)[0]
    // superGood 前后断言，匹配前后内容
    let reg = /(?<=generalpage\/)\d*(?=\/)/
    let imgId = d.match(reg)[0]
    imgInfo.push({
      urlName: urlName[i],
      imgId: imgId
    })
    console.log('imgId', imgId)
    // console.log('test', test[0].match(/\d+/)[0])
    fs.writeFileSync(__dirname + '/data2.json', JSON.stringify(imgInfo))
  })
}
